function fastSort(arr) {
  if (arr.length <= 1) {
    return arr
  }
  var left = []
  var right = []
  var halfNum = arr.splice(Math.floor(arr.length / 2), 1)
  for (var i = 0; i < arr.length; i++) {
    if (arr[i] < halfNum[0]) {
      left.push(arr[i])
    } else {
      right.push(arr[i])
    }
  }
  return fastSort(left).concat(halfNum, fastSort(right))
}
console.log(fastSort([1, 3, 2, 6, 3, 4, 9, 4, 2]))
function bubbleSort(arr) {
  if (arr.length <= 1) {
    return arr
  }
  for (var i = 0; i < arr.length; i++) {
    for (var j = 0; j < arr.length - i; j++) {
      if (arr[j] > arr[j + 1]) {
        temp = arr[j]
        arr[j] = arr[j + 1]
        arr[j + 1] = temp
      }
    }
  }
  return arr
}
console.log(bubbleSort([1, 3, 2, 6, 3, 4, 9, 4, 2]))
